// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import Vuex from 'vuex'
Vue.use(Vuex)

import ElementUI from 'element-ui'
import axios from 'axios'
import echarts from 'echarts'
import 'echarts-gl';
axios.defaults.withCredentials = true; //让ajax携带cookie
import "babel-polyfill"
import _ from 'lodash' //常用函数库
import moment from 'moment' //格式化时间的插件
// import 'lib-flexible' //可伸缩布局
import "bootstrap/dist/js/bootstrap.bundle.js" //bootstrap-colorpicker使用
import "bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js" //bootstrap-colorpicker使用
import * as $ from 'jquery';
//三方css
import 'element-ui/lib/theme-chalk/index.css'
import 'element-ui/lib/theme-chalk/display.css'
import './assets/styles/iconfont/iconfont.css';
import "bootstrap/dist/css/bootstrap.css";
import "bootstrap-colorpicker/dist/css/bootstrap-colorpicker.css";
import './assets/styles/reset.css';

import store from './store'

//放在引入的三方css后，在打包后，自定义的全局样式先被打包，然后是三方css，最后是自定义的组件样式
import router from './router'
//基于vue开发的插件才能使用use引入
Vue.use(ElementUI);

/*自定义插件*/
//各个项目都可用的通用全局函数
import factory from "./utils/factory"
Vue.use(factory);
//存储项目全局函数等
import projFun from "./utils/projFun"
Vue.use(projFun);
//存储全局指令
import Directive from "./directive/directive"
Vue.use(Directive);
//echarts注册主题，提供几种主题供选择，也可以在v-chart指令中自定义主题
import theme from '../static/json/echarts-theme.json'
for(const i in  theme){
  echarts.registerTheme(i,theme[i]);
}
//引用全部自定义组件
import SmartVIS from "../lib/smartVIS"
Vue.use(SmartVIS);
//按需引入自定义组件
// import {InputListView} from "../lib/smartVIS"
// Vue.use(InputListView);

Vue.config.productionTip = false;
Vue.prototype.jq = $; //jquery
Vue.prototype.axios = axios; //http请求库
Vue.prototype.echarts = echarts; //可视化库
Vue.prototype._ = _; //常用函数
Vue.prototype.moment = moment; //格式化时间
//插件方式引入
import httpRequest from "./utils/httpRequest"
Vue.use(httpRequest); //各个项目都可用的通用全局http


//import方式引入
/*import http from "./utils/httpRequestModule"
Vue.prototype.httpRequest = http.httpRequest; //与后台交互的http请求封装*/

// 白名单页面
const whiteList = ['/login']

// router.beforeEach((to, from, next) => {
//   let userInfo = sessionStorage.getItem('userInfo')
//   let menus = sessionStorage.getItem('menus')
//   if(to.path == '/login' || whiteList.indexOf(to.path) !== -1) {
//     next()
//   } else {
//     if(userInfo && menus && menus.indexOf(to.path !== -1)) { //未登录或者权限不够拦截跳转到登录页面, 权限足够则放行
//       next()
//     } else {
//       next('/login')
//     }
//   }
// })


/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: {
    App
  },
  template: '<App/>'
})
